package com.cp.order.platform;

import com.alibaba.fastjson.JSON;

public class ResultData {

	public static final int STATUS_OK = 0;
	public static final int STATUS_SERVER_ERROR = 1;
	public static final int STATUS_BUSINESS_ERROR = 2;

	private int status;
	private String msg;
	private Object result;

	public ResultData(int status, String msg) {
		super();
		this.status = status;
		this.msg = msg;
	}

	public ResultData(int status, String msg, Object data) {
		super();
		this.status = status;
		this.msg = msg;
		this.result = data;
		if (data instanceof String) {
			// 转化一下，这样格式化后的json串的时候能够更好阅读
			String temp = (String) data;
			if (temp.startsWith("{")) {
				this.result = JSON.parseObject(temp);
			} else if (temp.startsWith("[")) {
				this.result = JSON.parseArray(temp);
			}
		}
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

}
